﻿'******************************************************
'******************************************************
'Application Title: Google Widget Editor
'version: 1.0
'Date: 01-02-2008
'Requirements: win2k or later
'Author: Andrew Pye
'Author Email: StretchMasterP@googlemail.com
'License: Released under GNU GENERAL PUBLIC LICENSE v3
'ToDo:
'Changes:Imports System.Text
'******************************************************
'******************************************************

Imports System.Xml

''' <summary>
''' Class to handle list in the property grid
''' TODO:mAKE LOAD LIST DYNAMACALY
''' </summary>
''' <remarks>
''' </remarks>
Public Class RequireList : Inherits System.ComponentModel.StringConverter
    ' Dim _States As String() = New String() {"opensocial-0.8", "setprefs", "flash", "settitle"}
    Private _List As String
#Region "Functions"
    Public Overloads Overrides Function GetStandardValues(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.ComponentModel.TypeConverter.StandardValuesCollection
        Return New StandardValuesCollection(GetList("Require"))
    End Function
    Public Overloads Overrides Function GetStandardValuesSupported(ByVal context As System.ComponentModel.ITypeDescriptorContext) As Boolean
        Return True
    End Function
    Public Overloads Overrides Function GetStandardValuesExclusive(ByVal context As System.ComponentModel.ITypeDescriptorContext) As Boolean
        Return True
    End Function
    Private Function GetList(ByVal List As String) As String()
        Dim m_xmld As XmlDocument
        Dim m_nodelist As XmlNodeList
        Dim Tobj As XmlNode = Nothing

        m_xmld = New XmlDocument()
        'Load the Xml file

        m_xmld.Load(My.Application.Info.DirectoryPath & "\Data\" & List & "\" & List & ".xml")
        m_nodelist = m_xmld.GetElementsByTagName("Name")

        Dim Tstr As String = ""

        For Each Tobj In m_nodelist
            If Tstr = "" Then
                Tstr = Tobj.InnerText
            Else
                Tstr = Tstr & "," & Tobj.InnerText
            End If
        Next
        Dim Req() As String = Tstr.Split(",")
        Return Req
    End Function

#End Region
End Class
